package com.easy;

/**
 * Created by Lxk on 2020/2/19.
 */
class NumArray {

    private final int[] nums;

    public NumArray(int[] nums) {
        this.nums = nums;
    }

    public int sumRange(int i, int j) {
        int begin, end;
        begin = i >= 0 ? i : 0;
        end = j < nums.length ? j : nums.length - 1;
        int sum = 0;
        for (int k = begin; k <= end; k++) {
            sum += nums[k];
        }
        return sum;
    }
}

public class Solution303 {

    public static void main(String[] args) {

    }

}
